package com.stool.gramalldata.web;

import com.stool.gramalldata.domain.GramData;
import com.stool.gramalldata.domain.GramRequest;
import com.stool.gramalldata.domain.GramResponse;
import com.stool.gramalldata.domain.GramResult;
import com.stool.gramalldata.service.DLService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class GramController {

    @Autowired
    private DLService dlService;

    @PostMapping("/result")
    public GramResponse computeScore(@RequestBody GramRequest gramRequest) {

        List<GramResult> gramResults = dlService.computeResults(gramRequest.getData());

        GramResponse response = new GramResponse();
        response.setResults(gramResults);

        return response;
    }
}
